#include "rrvertexarray.h"
#include <cstring>

RRVertexArray::RRVertexArray()
{
    t = RR_TRIANGLE;    //hard coding
    v_num = 0;
    e_num = 0;
}

void RRVertexArray::rrAddVertex(RRVertex *arg)
{
    memcpy(&verts[v_num], arg, sizeof(RRVertex));
    v_num++;
}

void RRVertexArray::rrAddFace(int f1, int f2, int f3)
{
    elements[e_num][0] = f1;
    elements[e_num][1] = f2;
    elements[e_num][2] = f3;
    e_num++;
}

int RRVertexArray::rrGetVertsNum()
{
    return v_num;
}

int RRVertexArray::rrGetElemNum()
{
    return e_num;
}

void RRVertexArray::rrGetPrim(int index, RRPrim *prim)
{
    prim->rrReset();
    prim->rrBegin(RR_TRIANGLE);
    for(int i=0; i<3; i++)
        prim->rrSetVert(verts[elements[index][i]]);
    prim->rrEnd();
}
